<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class DidYouMean::TreeSpellChecker - did_you_mean: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-correct">#correct</a>
    <li ><a href="#method-i-correct_element">#correct_element</a>
    <li ><a href="#method-i-dictionary_without_leaves">#dictionary_without_leaves</a>
    <li ><a href="#method-i-dimensions">#dimensions</a>
    <li ><a href="#method-i-fall_back_to_normal_spell_check">#fall_back_to_normal_spell_check</a>
    <li ><a href="#method-i-find_ideas">#find_ideas</a>
    <li ><a href="#method-i-find_leaves">#find_leaves</a>
    <li ><a href="#method-i-find_suggestions">#find_suggestions</a>
    <li ><a href="#method-i-ideas_to_paths">#ideas_to_paths</a>
    <li ><a href="#method-i-normalize">#normalize</a>
    <li ><a href="#method-i-plausible_dimensions">#plausible_dimensions</a>
    <li ><a href="#method-i-possible_paths">#possible_paths</a>
    <li ><a href="#method-i-tree_depth">#tree_depth</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-DidYouMean::TreeSpellChecker">
    <h1 id="class-DidYouMean::TreeSpellChecker" class="class">
      class DidYouMean::TreeSpellChecker
    </h1>

    <section class="description">
    
<p>spell checker for a dictionary that has a tree structure, see doc/tree_spell_checker_api.md</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">



        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-augment" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">augment</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
          <div id="attribute-i-dictionary" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">dictionary</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
          <div id="attribute-i-separator" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">separator</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(dictionary:, separator: &#39;/&#39;, augment: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File did_you_mean/tree_spell_checker.rb, line 9</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-value">dictionary:</span>, <span class="ruby-value">separator:</span> <span class="ruby-string">&#39;/&#39;</span>, <span class="ruby-value">augment:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-ivar">@dictionary</span> = <span class="ruby-identifier">dictionary</span>
  <span class="ruby-ivar">@separator</span> = <span class="ruby-identifier">separator</span>
  <span class="ruby-ivar">@augment</span> = <span class="ruby-identifier">augment</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-correct" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">correct</span><span
                                class="method-args">(input)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="correct-source">
            <pre><span class="ruby-comment"># File did_you_mean/tree_spell_checker.rb, line 15</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">correct</span>(<span class="ruby-identifier">input</span>)
  <span class="ruby-identifier">plausibles</span> = <span class="ruby-identifier">plausible_dimensions</span>(<span class="ruby-identifier">input</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">fall_back_to_normal_spell_check</span>(<span class="ruby-identifier">input</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">plausibles</span>.<span class="ruby-identifier">empty?</span>

  <span class="ruby-identifier">suggestions</span> = <span class="ruby-identifier">find_suggestions</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">plausibles</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">fall_back_to_normal_spell_check</span>(<span class="ruby-identifier">input</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">suggestions</span>.<span class="ruby-identifier">empty?</span>

  <span class="ruby-identifier">suggestions</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-dictionary_without_leaves" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">dictionary_without_leaves</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="dictionary_without_leaves-source">
            <pre><span class="ruby-comment"># File did_you_mean/tree_spell_checker.rb, line 25</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">dictionary_without_leaves</span>
  <span class="ruby-ivar">@dictionary_without_leaves</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">dictionary</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">word</span><span class="ruby-operator">|</span> <span class="ruby-identifier">word</span>.<span class="ruby-identifier">split</span>(<span class="ruby-identifier">separator</span>)[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">-2</span>] }.<span class="ruby-identifier">uniq</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-dimensions" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">dimensions</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="dimensions-source">
            <pre><span class="ruby-comment"># File did_you_mean/tree_spell_checker.rb, line 33</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">dimensions</span>
  <span class="ruby-ivar">@dimensions</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">tree_depth</span>.<span class="ruby-identifier">times</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
                    <span class="ruby-identifier">dictionary_without_leaves</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">element</span><span class="ruby-operator">|</span> <span class="ruby-identifier">element</span>[<span class="ruby-identifier">index</span>] }.<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">uniq</span>
                  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-find_leaves" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">find_leaves</span><span
                                class="method-args">(path)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="find_leaves-source">
            <pre><span class="ruby-comment"># File did_you_mean/tree_spell_checker.rb, line 39</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">find_leaves</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">path_with_separator</span> = <span class="ruby-node">&quot;#{path}#{separator}&quot;</span>

  <span class="ruby-identifier">dictionary</span>
    .<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">str</span><span class="ruby-operator">|</span> <span class="ruby-identifier">str</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">path_with_separator</span>) }
    .<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">str</span><span class="ruby-operator">|</span> <span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">path_with_separator</span>, <span class="ruby-string">&#39;&#39;</span>) }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-plausible_dimensions" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">plausible_dimensions</span><span
                                class="method-args">(input)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="plausible_dimensions-source">
            <pre><span class="ruby-comment"># File did_you_mean/tree_spell_checker.rb, line 47</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">plausible_dimensions</span>(<span class="ruby-identifier">input</span>)
  <span class="ruby-identifier">input</span>.<span class="ruby-identifier">split</span>(<span class="ruby-identifier">separator</span>)[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">-2</span>]
    .<span class="ruby-identifier">map</span>
    .<span class="ruby-identifier">with_index</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">element</span>, <span class="ruby-identifier">index</span><span class="ruby-operator">|</span> <span class="ruby-identifier">correct_element</span>(<span class="ruby-identifier">dimensions</span>[<span class="ruby-identifier">index</span>], <span class="ruby-identifier">element</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">dimensions</span>[<span class="ruby-identifier">index</span>] }
    .<span class="ruby-identifier">compact</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-possible_paths" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">possible_paths</span><span
                                class="method-args">(states)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="possible_paths-source">
            <pre><span class="ruby-comment"># File did_you_mean/tree_spell_checker.rb, line 54</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">possible_paths</span>(<span class="ruby-identifier">states</span>)
  <span class="ruby-identifier">states</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">state</span><span class="ruby-operator">|</span> <span class="ruby-identifier">state</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">separator</span>) }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-tree_depth" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">tree_depth</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="tree_depth-source">
            <pre><span class="ruby-comment"># File did_you_mean/tree_spell_checker.rb, line 29</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">tree_depth</span>
  <span class="ruby-ivar">@tree_depth</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">dictionary_without_leaves</span>.<span class="ruby-identifier">max</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">b</span>.<span class="ruby-identifier">size</span> }.<span class="ruby-identifier">size</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-correct_element" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">correct_element</span><span
                                class="method-args">(names, element)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="correct_element-source">
            <pre><span class="ruby-comment"># File did_you_mean/tree_spell_checker.rb, line 93</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">correct_element</span>(<span class="ruby-identifier">names</span>, <span class="ruby-identifier">element</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">names</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">names</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>

  <span class="ruby-identifier">str</span> = <span class="ruby-identifier">normalize</span>(<span class="ruby-identifier">element</span>)

  <span class="ruby-keyword">return</span> [<span class="ruby-identifier">str</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">names</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">str</span>)

  <span class="ruby-operator">::</span><span class="ruby-constant">DidYouMean</span><span class="ruby-operator">::</span><span class="ruby-constant">SpellChecker</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">dictionary:</span> <span class="ruby-identifier">names</span>).<span class="ruby-identifier">correct</span>(<span class="ruby-identifier">str</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fall_back_to_normal_spell_check" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fall_back_to_normal_spell_check</span><span
                                class="method-args">(input)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="fall_back_to_normal_spell_check-source">
            <pre><span class="ruby-comment"># File did_you_mean/tree_spell_checker.rb, line 68</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fall_back_to_normal_spell_check</span>(<span class="ruby-identifier">input</span>)
  <span class="ruby-keyword">return</span> [] <span class="ruby-keyword">unless</span> <span class="ruby-identifier">augment</span>

  <span class="ruby-operator">::</span><span class="ruby-constant">DidYouMean</span><span class="ruby-operator">::</span><span class="ruby-constant">SpellChecker</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">dictionary:</span> <span class="ruby-identifier">dictionary</span>).<span class="ruby-identifier">correct</span>(<span class="ruby-identifier">input</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-find_ideas" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">find_ideas</span><span
                                class="method-args">(paths, leaf)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="find_ideas-source">
            <pre><span class="ruby-comment"># File did_you_mean/tree_spell_checker.rb, line 74</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">find_ideas</span>(<span class="ruby-identifier">paths</span>, <span class="ruby-identifier">leaf</span>)
  <span class="ruby-identifier">paths</span>.<span class="ruby-identifier">flat_map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">names</span> = <span class="ruby-identifier">find_leaves</span>(<span class="ruby-identifier">path</span>)
    <span class="ruby-identifier">ideas</span> = <span class="ruby-identifier">correct_element</span>(<span class="ruby-identifier">names</span>, <span class="ruby-identifier">leaf</span>)

    <span class="ruby-identifier">ideas_to_paths</span>(<span class="ruby-identifier">ideas</span>, <span class="ruby-identifier">leaf</span>, <span class="ruby-identifier">names</span>, <span class="ruby-identifier">path</span>)
  <span class="ruby-keyword">end</span>.<span class="ruby-identifier">compact</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-find_suggestions" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">find_suggestions</span><span
                                class="method-args">(input, plausibles)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="find_suggestions-source">
            <pre><span class="ruby-comment"># File did_you_mean/tree_spell_checker.rb, line 60</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">find_suggestions</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">plausibles</span>)
  <span class="ruby-identifier">states</span> = <span class="ruby-identifier">plausibles</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">product</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">plausibles</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>])
  <span class="ruby-identifier">paths</span>  = <span class="ruby-identifier">possible_paths</span>(<span class="ruby-identifier">states</span>)
  <span class="ruby-identifier">leaf</span>   = <span class="ruby-identifier">input</span>.<span class="ruby-identifier">split</span>(<span class="ruby-identifier">separator</span>).<span class="ruby-identifier">last</span>

  <span class="ruby-identifier">find_ideas</span>(<span class="ruby-identifier">paths</span>, <span class="ruby-identifier">leaf</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-ideas_to_paths" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">ideas_to_paths</span><span
                                class="method-args">(ideas, leaf, names, path)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="ideas_to_paths-source">
            <pre><span class="ruby-comment"># File did_you_mean/tree_spell_checker.rb, line 83</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ideas_to_paths</span>(<span class="ruby-identifier">ideas</span>, <span class="ruby-identifier">leaf</span>, <span class="ruby-identifier">names</span>, <span class="ruby-identifier">path</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">ideas</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">names</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">leaf</span>)
    [<span class="ruby-node">&quot;#{path}#{separator}#{leaf}&quot;</span>]
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">ideas</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">str</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;#{path}#{separator}#{str}&quot;</span> }
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-normalize" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">normalize</span><span
                                class="method-args">(str)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="normalize-source">
            <pre><span class="ruby-comment"># File did_you_mean/tree_spell_checker.rb, line 103</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">normalize</span>(<span class="ruby-identifier">str</span>)
  <span class="ruby-identifier">str</span>.<span class="ruby-identifier">downcase!</span>
  <span class="ruby-identifier">str</span>.<span class="ruby-identifier">tr!</span>(<span class="ruby-string">&#39;@&#39;</span>, <span class="ruby-string">&#39; &#39;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">str</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;@&#39;</span>)
  <span class="ruby-identifier">str</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

